﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace QuickLifeHall.Facade.Utilities
{
    public class FacadeBase : AjaxPro.Web.UI.AjaxBasePage
    {
        /// <summary>
        /// 是否登陆
        /// </summary>
        protected bool IsLogin = false;

        /// <summary>
        /// 当前登陆用户
        /// </summary>
        protected Entity.SystemBase.User LoginUser = null;

        /// <summary>
        /// 页面访问类型，默认需要登陆，并过滤权限
        /// </summary>
        protected Core.Web.PageAccessType PageAccessType = Core.Web.PageAccessType.Authorization;

        public FacadeBase()
            : base()
        {
            this.IsLogin = Facade.Utilities.PermissionUtility.IsLogin(this.Context, out LoginUser);

            if (PageAccessType == Core.Web.PageAccessType.Authorization)
            {
                if (!IsLogin || this.LoginUser == null)
                {
                    //验证失败，用户未登录
                    throw new Exception("未授权的操作！");
                }
            }
        }
    }
}
